package gameBasicElements;

/**
 * @author Tomasz Wiatrowski
 *
 */
@SuppressWarnings("serial")
public class StandardBoard extends AbstractBoard {

	public StandardBoard(int size){
		super(size);
	}
	
	private StandardBoard(AbstractBoard board, Position pos, PlayerColor color){
		super(board, pos, color);
	}
	
	private StandardBoard(AbstractBoard board, Move move){
		super(board, move);
	}
	
	@Override
	public Position[] getNeighbours(Position pos) {
		int neighbours = 4, point = 0; 
		if(pos.getX()==0||pos.getX()==getSize()-1)
			--neighbours;
		if(pos.getY()==0||pos.getY()==getSize()-1)
			--neighbours;
		Position[] res = new Position[neighbours];
		if(pos.getX()>0){
			res[point] = new Position(pos.getX()-1, pos.getY());
			++point;
		}
		if(pos.getX()<getSize()-1){
			res[point] = new Position(pos.getX()+1, pos.getY());
			++point;
		}
		if(pos.getY()>0){
			res[point] = new Position(pos.getX(), pos.getY()-1);
			++point;
		}
		if(pos.getY()<getSize()-1){
			res[point] = new Position(pos.getX(), pos.getY()+1);
			++point;
		}
		return res;
	}

	@Override
	public StandardBoard update(Move move) {
		return new StandardBoard(this, move);
	}
	
	@Override
	public StandardBoard placeStone(Move move){
		return new StandardBoard(this, move.getPosition(), move.getColor());
	}
}
